package com.teradyne.merlin2.ui.client.activities;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.teradyne.merlin2.ui.client.places.ServiceAddAddressPlace;
import com.teradyne.merlin2.ui.client.places.ServiceChangeAddressPlace;
import com.teradyne.merlin2.ui.client.places.ServiceInstallProblemPlace;
import com.teradyne.merlin2.ui.client.places.ServiceOtherPlace;
import com.teradyne.merlin2.ui.client.places.ServicestListPlace;
import com.teradyne.merlin2.ui.client.views.ServicesMenuView;

public class ServicesMenuActivity extends AbstractActivity implements
		ServicesMenuView.Presenter, ActivityCustom {

	private final ServicesMenuView view;
	private final PlaceController placeController;
	private Place place;

	private List<HandlerRegistration> handlerRegistration = new ArrayList<HandlerRegistration>();

	public ServicesMenuActivity(ServicesMenuView view,
			PlaceController placeController) {
		this.view = view;
		this.placeController = placeController;
	}

	@Override
	public void start(final AcceptsOneWidget container, final EventBus eventBus) {
		container.setWidget(view.asWidget());
		view.setPresenter(ServicesMenuActivity.this);
	}

	@Override
	public void onServiceListClicked() {
		placeController.goTo(new ServicestListPlace());
	}

	@Override
	public void onServiceInstallProblemClicked() {
		placeController.goTo(new ServiceInstallProblemPlace());
	}

	@Override
	public void onAddAddressClicked() {
		placeController.goTo(new ServiceAddAddressPlace());
	}

	@Override
	public void onChangeAddressClicked() {
		placeController.goTo(new ServiceChangeAddressPlace());
	}

	@Override
	public void onOtherServiceClicked() {
		placeController.goTo(new ServiceOtherPlace());
	}

	@Override
	public void setPlace(Place place) {
		this.place = place;
	}

	@Override
	public Place getPlace() {
		return place;
	}

}